﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DevComponents.DotNetBar;

namespace MetroControl
{
    public class BaseUserControl : UserControl
    {
        private string closeButtonName;
        public string CloseButtonName
        {
            get { return string.IsNullOrEmpty(closeButtonName) ? "btnClose" : closeButtonName; }
            set
            {
                closeButtonName = value;
            }
        }

        public virtual void BindCloseControl(EventHandler eventHandler)
        {
            foreach (Control control in this.Controls)
            {
                if (control.Name == CloseButtonName && control is ButtonX)
                {
                    ButtonX closeButton = control as ButtonX;
                    closeButton.Command = new Command(eventHandler);
                }
            }
        }
    }
}
